package com.ssy.lingxi.after.sale.repository;

import com.ssy.lingxi.after.sale.entity.ReturnGoodsDetailDO;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;

import javax.transaction.Transactional;
import java.util.List;
import java.util.Set;

/**
 * 退货商品
 * @author 伍将
 * @date 2020/9/9
 * @version 2.0.0
 */
public interface ReturnGoodsDetailRepository extends JpaRepository<ReturnGoodsDetailDO, Long>, JpaSpecificationExecutor<ReturnGoodsDetailDO> {

    /**
     * 根据退货id删除退货商品
     * @author 伍将
     * @date 2020/9/9
     * @param returnId:
     * @return void
     **/
    @Transactional
    void deleteAllByReturnId(Long returnId);

    /***
     * 根据退货id与是否退货条件检查是否存在退货商品
     * @author 伍将
     * @date 2020/9/24
     * @param returnId:
     * @param isNeedReturn:
     * @return java.lang.Boolean
     **/
    Boolean existsByReturnIdAndIsNeedReturn(Long returnId, Integer isNeedReturn);

    /**
     * 根据退货id查询所有退货商品
     * @author 伍将
     * @date 2020/9/24
     * @param returnId:
     * @return List<ReturnGoodsDetailDO>
     **/
    List<ReturnGoodsDetailDO> findByReturnId(Long returnId);

    /**
     * 根据合同id查询所有退货商品
     * @author 伍将
     * @date 2020/9/24
     * @param contractId:
     * @return List<ReturnGoodsDetailDO>
     **/
    List<ReturnGoodsDetailDO> findByContractId(Long contractId);

    /**
     * 根据退货ids查询所有退货商品
     * @param returnIds
     * @return
     */
    List<ReturnGoodsDetailDO> findByReturnIdIn(Set<Long> returnIds);
}
